<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="ceph" uri="http://jsp.cephb.fr" %>
<%@page import="fr.cephb.joperon.core.bio.Assembly"%><c:set var="page_title" scope="request" value="Project ${requestScope.project.pid}"/>
<jsp:include page="xhtml-header.jsp"/>

<div>

<c:url var="url" value="/operon" >
<c:param name="act" value="prjmgr-edit" />
<c:param name="id" value="${requestScope.project.pid}" />
<c:param name="view" value="users" /></c:url>
<a href="${url}">Members</a>

<c:url var="url" value="/operon" >
<c:param name="act" value="prjmgr-edit" />
<c:param name="id" value="${requestScope.project.pid}" />
<c:param name="view" value="adduser" /></c:url>
<a href="${url}">Add Member</a>

<c:url var="url" value="/operon" >
<c:param name="act" value="prjmgr-edit" />
<c:param name="id" value="${requestScope.project.pid}" />
<c:param name="view" value="addprjfin" /></c:url>
<a href="${url}">Add List Of SNPs</a>

<c:url var="url" value="/operon" >
<c:param name="act" value="prjmgr-edit" />
<c:param name="id" value="${requestScope.project.pid}" />
<c:param name="view" value="" /></c:url>
<a href="${url}">View Content</a>

</div>

<c:choose>
	<c:when test="${param.view == 'users'}">
		<form action="${pageContext.request.contextPath}/operon" method="post">
		<input type="hidden" value="${requestScope.project.pid}" name="project-id"/>
		
		<table>
		<caption>Project Members</caption>
		<thead>
		<tr><th>ID</th><th>Name</th><th/></tr>
		</thead>
		<tbody class="scrollable">
		<c:forEach var="user" items="${requestScope.users}">
			<ceph:tr>
			<td><input value="${user.id}" name="user-id" type="checkbox"/> <c:out value="${user.id}" /></td>
			<td><c:out value="${user.login}" /></td>
			</ceph:tr>
		</c:forEach>
		</tbody></table>
		<select name="act">
		 <option value="prjmgr-remove-user">Remove User</option>
		 <option value="prjmgr-user-write">Set As Administrator</option>
		 <option value="prjmgr-user-read">Set As Read-only User</option>
		</select><input type="submit" value="Submit"/><br/>
		</form>
	</c:when>

	<c:when test="${param.view == 'adduser'}">
		<form action="${pageContext.request.contextPath}/operon" method="post">
		<fieldset>
		<legend>Add a new User</legend>
		<input type="hidden" value="${requestScope.project.pid}" name="project-id"/>
		<input type="hidden" name="act" value="prjmgr-add-user"/>
		<label>Add User</label> <input type="text" name="user-login" value="" size="20"/> <input type="submit" value="Add User"/>
		</fieldset>
		</form>
	</c:when>
	
	<c:when test="${param.view =='addprjfin'}">
		<!--  BEGIN INSERT A NEW PRJFIN -->
		<%
		pageContext.setAttribute("assemblies",fr.cephb.joperon.core.bio.Assembly.getAssemblies());
		%>
		
		<form action="${pageContext.request.contextPath}/operon" method="post" enctype="multipart/form-data">
		<input type="hidden"  name="project-id" value="${requestScope.project.pid}"/>
		<input type="hidden" name="act" value="prjfin-new"/>
		<fieldset>
		<legend>Upload a new List of SNP</legend>
		<ul>
			<li>
				<label>Project Definition</label>
				<input type="text" name="def" value="${param.def}"/>
			</li>
			<li>
				<label>Assembly</label>
				<select name="as">
				<option value="">---</option>
				<c:forEach var="as" items="${pageScope.assemblies}">
					<c:choose>
					<c:when test="${as.id eq pageScope.assembly.id }">
						<option value="${as.id}" selected="true">
							<c:out value="${as.name}"/>
						</option>
					</c:when>
					<c:otherwise>
						<option value="${as.id}">
							<c:out value="${as.name}"/>
						</option>
					</c:otherwise>
					</c:choose>
					
				</c:forEach>
				</select>
			</li>
			<li>
				<label>The file of SNP</label>
				<input type="file" name="file"/>
			</li>
		</ul>
		<input type="submit" value="Upload"/>
		</fieldset>
		</form>
		
		
		<!--  END INSERT A NEW PRJFIN -->
	</c:when>

	<c:otherwise>

		<h2>Project SNP</h2>
		<table>
		<caption>Project SNP</caption>
		<thead>
			<tr>
				<th>ID</th>
				<th>Def</th>
				<th>Assembly</th>
				<th>Date</th>
				<th>User</th>
			</tr>
		</thead>
		<tbody class="scrollabel">
		<c:forEach var="prjfin" items="${prjfins}">
			<c:if test="${prjfin.target=='DNA' or prjfin.target=='SNP' }">
			<ceph:tr>
				<td>
					<c:choose>
						<c:when test="${not empty prjfin.assembly and prjfin.target.prefix eq 'S'}">
							<c:url var="url" value="/operon" >
					  		<c:param name="act" value="prjsnp-edit" />
							<c:param name="pid" value="${prjfin.pid}" />
							<c:param name="fix" value="${prjfin.fix}" /></c:url>
							<a href="${url}">SNP-set <c:out value="${prjfin.fix}" /></a>
						</c:when>
						<c:when test="${prjfin.target.prefix eq 'D'}">
							<c:url var="url" value="/operon" >
					  		<c:param name="act" value="prjdna-edit" />
							<c:param name="pid" value="${prjfin.pid}" />
							<c:param name="fix" value="${prjfin.fix}" /></c:url>
							<a href="${url}">Population <c:out value="${prjfin.fix}" /></a>
						</c:when>
					<c:otherwise>
						<c:out value="${prjfin.fix}" />
		  			</c:otherwise>
					</c:choose>
				</td>
				<td><c:out value="${prjfin.def}" /></td>
				<td><c:if test="${not empty prjfin.assembly}"><c:out value="${prjfin.assembly.name}" /></c:if></td>
				<td><c:out value="${prjfin.ymd}" /></td>
				<td><c:out value="${prjfin.log}" /></td>
			</ceph:tr>
			</c:if>
		</c:forEach>
		</tbody></table>
	</c:otherwise>

</c:choose>
<jsp:include page="xhtml-footer.jsp"/>
